package com.tcl.logoidentify.web.api;

import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.io.Files;

import jodd.io.FileUtil;
import jodd.util.ThreadUtil;

@WebServlet("/api/v1/logoidentify/config")
public class Config extends HttpServlet {
	private final static Logger LOGGER = LoggerFactory.getLogger(Search.class);
	private static final long serialVersionUID = 1L;
	private static String config = null;
	static {
		try {
			config = FileUtil.readString(new File(Thread.currentThread().getContextClassLoader().getResource("client-config.json").getPath()));
		} catch (IOException e) {
			LOGGER.error("加载终端配置文件出错", e);
		}
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.getWriter().write(config);
	}

}
